package com.itestor.iptv.modules.common.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.itestor.iptv.global.GlobalConstant;
import com.itestor.iptv.modules.common.bean.SystemConfigBean;
import com.itestor.iptv.modules.common.service.RobotConfigService;

/**
 * 
 * @author Mr.li
 * 
 */
public class RobotSystemCfgModifyAction extends Action {

    /**
     * Logger for this class.
     */
    private static final Logger logger = Logger
            .getLogger(RobotSystemCfgModifyAction.class);
    
    /**
	 * 
	 */
    public transient RobotConfigService robotConfigService;

    /**
     * @param mapping struts mapping
     * @param request request
     * @param form action form
     * @param response response
     * @return action forward
     * @throws Exception any exception
     */
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        String hostIp = request.getParameter("hostIp");
        String systemTime = request.getParameter("systemTime");
        String systemDate = request.getParameter("systemDate");        
        String ntpServer = request.getParameter("ntpServer");
        String subnetMask=request.getParameter("subnetMask");
        String gateway=request.getParameter("gateway");
        String adapterName=request.getParameter("adapterName");
        
        //String ntpStatus = request.getParameter("ntpStatus");
        
        SystemConfigBean bean=new SystemConfigBean();
        bean.setHostIp(hostIp);
        bean.setNtpServer(ntpServer);
        //bean.setNtpStatus(ntpStatus);
        bean.setSystemTime(systemTime);
        bean.setSystemDate(systemDate);
        bean.setAdapterName(adapterName);
        bean.setGateway(gateway);
        bean.setSubnetMask(subnetMask);
        
        robotConfigService.modifySystemConfig(bean); 
        
        return mapping.findForward(GlobalConstant.FORWARD_SUCCESS);
    }
    
    /** 
     * @param pRobotConfigService
     */
    public void setRobotConfigService(RobotConfigService pRobotConfigService) {
        robotConfigService = pRobotConfigService;
    }

}
